package com.maxima.maximaAttendance.actions;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.maxima.maximaAttendance.daos.UserDAO;
import com.maxima.maximaAttendance.pojos.User;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class UserActions extends ActionSupport implements ModelDriven<User>{

	private static final long serialVersionUID = 1L;
	
	private User user=new User();
	
	
	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}

	public String addNewUser() {
//		this.user.setFirstname(ServletActionContext.getRequest().getParameter("firstname"));
//		this.user.setLastname(ServletActionContext.getRequest().getParameter("lastname"));
//		this.user.setEmp_id(Integer.parseInt(ServletActionContext.getRequest().getParameter("emp_id")));
		this.user.setPassword(ServletActionContext.getRequest().getParameter("password"));
//		this.user.setProject(ServletActionContext.getRequest().getParameter("project"));
		new UserDAO().add(this.user);
		return SUCCESS;
	}
	

	public List<User> getAllUsers() {
		return new UserDAO().getAllUsers();
	}

	@Override
	public User getModel() {
		return this.user;
	}
	

}
